<?php
declare(strict_types=1);

// +----------------------------------------------------------------------
// | 兔兔答题考试系统
// +----------------------------------------------------------------------
// | 感谢使用兔兔答题考试系统
// | 本系统经过商业授权，不能转售、开源或者以其他方式进行使用，只可在购买协议范围内容使用
// | 若发现未被版权协议，将追究相应的公司、团队、企业等
// | 访问官网：https://www.tutudati.com
// | 兔兔答题考试系统开发者版权所有 拥有最终解释权

namespace App\Logic\User\Service\Video;

use App\Logic\User\Repository\Video\VideoTagRepository;
use App\Logic\User\Service\BaseService;
use App\Logic\User\Service\UserServiceInterface;
use Closure;

class VideoTagService extends BaseService implements UserServiceInterface
{

    public static function searchWhere(array $requestParams): Closure
    {
        return function ($query) use ($requestParams) {
            if (!empty($requestParams["is_top"])) {
                $query->where("is_top", "=", $requestParams["is_top"]);
            }
            $query->where("is_show", "=", 1);
        };
    }

    public function serviceSelect(array $requestParams): array
    {
        $list = [];
        $list[] = ["uid" => "", "title" => "全部", "url" => "", "image" => ""];
        $items = (new VideoTagRepository())->repositorySelect(self::searchWhere($requestParams), 1000,
            ["uid", "title", "url", "image"]);
        foreach ($items as $value) {
            $list[] = $value;
        }
        return $list;
    }

    public function serviceCreate(array $requestParams): array
    {
        // TODO: Implement serviceCreate() method.
    }

    public function serviceUpdate(array $requestParams): array
    {
        // TODO: Implement serviceUpdate() method.
    }

    public function serviceDelete(array $requestParams): int
    {
        // TODO: Implement serviceDelete() method.
    }

    public function serviceFind(array $requestParams): array
    {
        // TODO: Implement serviceFind() method.
    }
}
